"""
响应体 Model 分页基类
"""

from typing import List

from pydantic import (
    BaseModel,
    Field,
)

import utils.enum_utils as enum


class OK(BaseModel):
    """ 成功 """

    code: int = Field(
        enum.HTTPStatusCode.HTTP_200_OK.value,
        title="响应状态码",
    )

    message: str = Field(
        enum.HTTPStatusCode.get_en_label(enum.HTTPStatusCode.HTTP_200_OK),
        title="响应消息",
    )


class OKWithData(OK):
    """ 成功（带数据） """

    data: dict = Field(
        ...,
        title="响应数据",
    )


class OKWithPage(OK):
    """ 成功（带分页数据） """

    page: int = Field(
        ...,
        title="页码",
        ge=1,
    )

    page_size: int = Field(
        ...,
        title="每页数据条数",
        ge=1,
    )

    page_count: int = Field(
        ...,
        title="总页数",
        ge=0,
    )

    data_count: int = Field(
        ...,
        title="总数据条数",
        ge=0,
    )

    data_list: List[dict] = Field(
        ...,
        title="分页后的数据",
    )
